package model

import model.events.{
  BaseEvent,
  GroupJoin,
  GroupLeave,
  LikeAdd,
  LikeRemove,
  WallReplyNew,
  WallRepost
}
import zio.json.*

object Utils {
  def ConvertToJsonByTopic(topic: String, event: String): Either[String, BaseEvent] =
    topic match {
      case "like_remove"    => event.fromJson[LikeRemove]
      case "like_add"       => event.fromJson[LikeAdd]
      case "group_leave"    => event.fromJson[GroupLeave]
      case "group_join"     => event.fromJson[GroupJoin]
      case "wall_repost"    => event.fromJson[WallRepost]
      case "wall_reply_new" => event.fromJson[WallReplyNew]
    }
}
